package com.xianbeiying.app.ckgl.model;

import android.content.Context;
import android.util.Log;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.xianbeiying.app.ckgl.MyApplication;
import com.xianbeiying.app.ckgl.bean.CreatPlantBean;
import com.xianbeiying.app.ckgl.bean.EZdBean;
import com.xianbeiying.app.ckgl.bean.EZqBean;
import com.xianbeiying.app.ckgl.bean.JsonBean;
import com.xianbeiying.app.ckgl.bean.SFmTypeBean;
import com.xianbeiying.app.ckgl.bean.UrlBean;
import com.xianbeiying.app.ckgl.http.HttpPostManger;
import com.xianbeiying.app.ckgl.util.DialogUtile;
import com.xianbeiying.app.ckgl.util.LogUtils;
import com.xianbeiying.app.ckgl.util.ToastUtil;

import java.util.ArrayList;
import java.util.List;

import cz.msebera.android.httpclient.Header;
/**
 * 设置信息
 */
public class SetModel extends BaseModel {

    private AsyncHttpClient client;
    private RequestParams params;
    private Context context;

    public SetModel(Context context) {
        this.context = context;
        client = new AsyncHttpClient();
         params = new RequestParams();
//        MyApplication.IP= SharedPreferencesUtils.getStringDate("ip","120.26.96.123");
}
    /**
     * 设置阀门的状态信息
     * */

    public void OPEN_SWITCH_STATUS(SFmTypeBean jsonDataBean, boolean isDiaylog){
        if (isDiaylog){
            DialogUtile.showLoading(context);
        }
        LogUtils.e("设置阀门","http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT+ JsonBean.openFmString(jsonDataBean)+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT,JsonBean.openFmString(jsonDataBean), new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("阀门设置返回值",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("设置阀门",responseBody);
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }
    /**
     * 设置风机的状态信息
     * */
    public void SETFENJI(SFmTypeBean jsonDataBean, boolean isDiaylog){
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        LogUtils.e("设置风机","http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT+JsonBean.openFmString(jsonDataBean)+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT,JsonBean.openFmString(jsonDataBean), new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("风机设置返回值",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("设置风机",responseBody);
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }
    /**
     * 设置卷帘
     * */
    public void SETJLDetauls(SFmTypeBean jsonDataBean, boolean isDiaylog){
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        LogUtils.e("设置卷帘","http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT+JsonBean.openFmString(jsonDataBean)+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT,JsonBean.openFmString(jsonDataBean), new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("卷帘设置返回值",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("设置卷帘",responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    public void SET_CYCLEPLANSS(String k, int code, int EQPTYPE, List<EZqBean> arrayList, boolean isDiaylog) {
        if (isDiaylog){
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.ezqString(k,code,EQPTYPE,arrayList);
        LogUtils.e("设置阀门周期","http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("设置阀门周期返回值",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("设置阀门周期",responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值","----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    public void SET_TRIGGERPLANSS(String k, int code, int  EQPTYPE, List<EZdBean> arrayList, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.ezdString(k,code,EQPTYPE,arrayList);
        LogUtils.e("设置智能计划","http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("设置智能计划返回值",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("设置智能计划",responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     * 启动周期性阀门计划
     * SYSTEMID:系统编号
     * CODE:计划编号
     */
    public void START_CYCLEPLANS(String k,long SYSTEMID, int CODE, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.zqPlantString(k,SYSTEMID,CODE);
        LogUtils.e("启动周期性阀门","http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("启动周期性阀门返回值",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("启动周期性阀门",responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                    //关闭加载
                    DialogUtile.closeDialog();
                    LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     *启动智能阀门计划
     * SYSTEMID:系统编号
     * CODE:计划编号
     */
    public void START_TRIGGERPLANS(String k,long SYSTEMID, int CODE, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.zqPlantString(k,SYSTEMID,CODE);
        LogUtils.e("启动智能计划","http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("启动智能计划返回值",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("启动智能计划",responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }
    /**
     *停止周期性阀门计划
     * SYSTEMID:系统编号
     * CODE:计划编号
     */
    public void STOP_CYCLEPLANS(String k,long SYSTEMID, int CODE, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.zqPlantString(k,SYSTEMID,CODE);
        LogUtils.e("停止周期性阀门","http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("停止周期性阀门返回值",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("停止周期性阀门",responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }
    /**
     *停止智能计划计划
     * SYSTEMID:系统编号
     * CODE:计划编号
     */
    public void STOP_TRIGGERPLANS(String k,long SYSTEMID, int CODE, boolean isDiaylog) {
        if (isDiaylog){
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.zqPlantString(k,SYSTEMID,CODE);
        LogUtils.e("停止智能计划","http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("停止智能计划返回值",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("停止智能计划",responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }
    /**
     * 专家预约
     * */
    public void ADDExpertOrder(String k,String CONTENT,String  NAME,String  TEL,boolean isDiaylog) {
        if (isDiaylog){
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.yuyueString(k,CONTENT,NAME,TEL);
        LogUtils.e("专家预约","http://"+MyApplication.IP+UrlBean.YUYUE+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.YUYUE,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("专家预约",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("专家预约",responseBody);
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }
    /**
     * 远程诊断
     * */
    public void ADDDiagnose(String k,String CONTENT,String  NAME,String  TEL,ArrayList<String> image, boolean isDiaylog) {
        if (isDiaylog){
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.zhenDuanString(k,CONTENT,NAME,TEL,image);
        LogUtils.e("远程诊断","http://"+MyApplication.IP+UrlBean.EXPERT_DIAGNOSE+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.EXPERT_DIAGNOSE,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("远程诊断",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("远程诊断",responseBody);
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     * 收藏精选
     * */
    public void ADDCOLLECT(String k,int  ID,int  USERID, boolean isDiaylog) {
        if (isDiaylog){
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.collectString(k,ID,USERID);
        LogUtils.e("收藏精选","http://"+MyApplication.IP+UrlBean.ADDCOLLECT+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.ADDCOLLECT,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("收藏精选",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("收藏精选",responseBody);
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }
    /**
     * 收藏种植模型
     * */
    public void ADDCOLLECTPlant(String k,int  CROPID,int CROPTYPE,int  PLANTTYPE,int USERID, boolean isDiaylog) {
        if (isDiaylog){
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.collectPlantString(k,CROPID,CROPTYPE,PLANTTYPE,USERID);
        LogUtils.e("收藏种植模型","http://"+MyApplication.IP+UrlBean.ADDCOLLECTPLABT+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.ADDCOLLECTPLABT,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("收藏种植模型",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("收藏种植模型",responseBody);
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }
    /**
     * 个人中心中
     * 温室主人
     * */
    public void SETGHPerson(String realusername,String  tel,int USERID, boolean isDiaylog) {
        if (isDiaylog){
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.changePersonString(realusername,tel,USERID);
        LogUtils.e("温室主人","http://"+MyApplication.IP+UrlBean.USERMANAGER+"update_user"+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.USERMANAGER+"update_user",url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody){
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("温室主人",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("温室主人",responseBody);
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }
    /**
     * 个人中心中
     * 修改密码
     * */
    public void ChangePaw(String username,String  password,String  changePwdString, boolean isDiaylog) {
        if (isDiaylog){
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.changePwdString(username,password,changePwdString);
        LogUtils.e("修改密码","http://"+MyApplication.IP+UrlBean.Change_passwd+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.Change_passwd,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("修改密码",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("修改密码",responseBody);
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }
  /**
   * 添加地点
   * */
    public void ADDAdress(String k,long SYSTEMID,String  DATETIME, boolean isDiaylog) {
        if (isDiaylog){
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.timeString(k,SYSTEMID,DATETIME);
        LogUtils.e("添加地点","http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("添加地点",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("添加地点",responseBody);
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     * 创建作物
     * */
    public void CREATE_CROP(String k,int CROPTYPE,String  CROPNAME, String CROPIMAGE,boolean isDiaylog) {
        if (isDiaylog){
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.createPlant(k,CROPTYPE,CROPNAME,CROPIMAGE);
        LogUtils.e("创建作物","http://"+MyApplication.IP+UrlBean.CREATE_CROP+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.CREATE_CROP,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("创建作物",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("创建作物",responseBody);
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }
    /**
     * 创建作物类型
     * */
    public void CREATE_CROP_TYPE(String k,String  CROPTYPENAME, boolean isDiaylog) {
        if (isDiaylog){
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.createPlantType(k,CROPTYPENAME);
        LogUtils.e("创建作物类型","http://"+MyApplication.IP+UrlBean.CREATE_CROP_TYPE+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.CREATE_CROP_TYPE,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("创建作物类型",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("创建作物类型",responseBody);
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }
    /**
     * 创建大棚的农作物生产周期，以及生长阶段
     * */
    public void CREATE_CROPSTEPss(String k,ArrayList<String> CROPID,String CROPTYPE,String PLANTTYPE,ArrayList<String> PLANTNAME,ArrayList<CreatPlantBean> creatPlantBeen,boolean isDiaylog) {
        if (isDiaylog){
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.createPlantInfoss(k,CROPID,CROPTYPE,PLANTTYPE,PLANTNAME,creatPlantBeen);
        LogUtils.e("创建大棚种植信息","http://"+MyApplication.IP+UrlBean.CREATE_CROPSTEP+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.CREATE_CROPSTEP,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("创建大棚种植信息",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("创建大棚种植信息",responseBody);
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }
    /**
     *时间校验
     * */

    public void SET_DATE(String k,int GREENHOUSEID,String DATETIME,boolean isDiaylog) {
        if (isDiaylog){
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.timeDateString(k,GREENHOUSEID,DATETIME);
        LogUtils.e("时间校验","http://"+MyApplication.IP+UrlBean.SET_DATE+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.SET_DATE,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("时间校验",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("时间校验",responseBody);
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }


    /**
     *更新大棚
     * */

    public void UPDATE_GREENHOUSE(String k,int GREENHOUSEID,String HOUSENAME,String CROPID,String CROPTYPE,String GROWTYPE
            ,String HOUSEADD_PRO,String HOUSEADD_CITY,String HOUSEADD_DIST,String HOUSEADD_OTHER,String HOUSEAREA,String HOUSETYPE,String HOUSETYPENAME,String
                                          HOUSEX,String HOUSEY,String PLANTDURATION,String PLANTTIME,String PLANTAREA,
                                  String PRODUCTION,String SOILK, String SOILN,String SOILP ,boolean isDiaylog) {
        if (isDiaylog){
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.updateDpString(k,GREENHOUSEID,HOUSENAME,CROPID,CROPTYPE,GROWTYPE,HOUSEADD_PRO,HOUSEADD_CITY,HOUSEADD_DIST,HOUSEADD_OTHER,HOUSEAREA,HOUSETYPE,
                HOUSETYPENAME,HOUSEX, HOUSEY,PLANTDURATION,PLANTTIME,PLANTAREA,PRODUCTION,SOILK,SOILN,SOILP);
        LogUtils.e("更新大棚","http://"+MyApplication.IP+UrlBean.UPDATE_GREENHOUSE+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.UPDATE_GREENHOUSE,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("更新大棚",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("更新大棚",responseBody);
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }
    /**
     * 获取验证码
     * */

    public void get_verification_code(String username,String  tel,boolean isDiaylog) {
        if (isDiaylog){
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.getCodeString(username,tel);
        LogUtils.e("获取验证码","http://"+MyApplication.IP+UrlBean.get_verification_code+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.get_verification_code,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("获取验证码",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("获取验证码",responseBody);
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     *验证
     * */
    public void check_verification_code(String username,String  verCode,boolean isDiaylog) {
        if (isDiaylog){
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.getYCodeString(username,verCode);
        LogUtils.e("验证","http://"+MyApplication.IP+UrlBean.check_verification_code+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.check_verification_code,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("验证",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("验证",responseBody);
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     * 重置密码
     * */

    public void resetPwd(String username,String  password,boolean isDiaylog) {
        if (isDiaylog){
            DialogUtile.showLoading(context);
        }
        String url=JsonBean.restPwdString(username,password);
        LogUtils.e("重置密码","http://"+MyApplication.IP+UrlBean.reset_passwd+url+"======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.reset_passwd,url, new AsyncHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("重置密码",new String(responseBody));
                //函数返回值
                SetModel.this.onCallBackData("重置密码",responseBody);
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------"+statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }
}
